{# Stalker Pyramid a Web Base Production Asset Management System
 Copyright (C) 2009-2014 Erkan Ozgur Yilmaz
 
 This file is part of Stalker Pyramid.
 
 This library is free software; you can redistribute it and/or
 modify it under the terms of the GNU Lesser General Public
 License as published by the Free Software Foundation;
 version 2.1 of the License.

 This library is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 Lesser General Public License for more details.

 You should have received a copy of the GNU Lesser General Public
 License along with this library; if not, write to the Free Software
 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#}
<div class='dijitDialogPaneContentArea'>
    <div id='repository_form'>
        <table style='width: 100%'>

            {# NAME #}
            <tr>
                <td class='label_column'>
                    <label for='repository_name'>
                        Name
                    </label>
                </td>
                <td class='input_column'>
                    <input id='repository_name'>
                </td>
            </tr>

            {# WINDOWS_PATH #}
            <tr>
                <td class='label_column'>
                    <label for='repository_windows_path'>
                        Windows Path
                    </label>
                </td>
                <td class='input_column'>
                    <input id='repository_windows_path'>
                </td>
            </tr>

            {# LINUX_PATH #}
            <tr>
                <td class='label_column'>
                    <label for='repository_linux_path'>
                        Linux Path
                    </label>
                </td>
                <td class='input_column'>
                    <input id='repository_linux_path'>
                </td>
            </tr>

            {# OSX_PATH #}
            <tr>
                <td class='label_column'>
                    <label for='repository_osx_path'>
                        OSX Path
                    </label>
                </td>
                <td class='input_column'>
                    <input id='repository_osx_path'>
                </td>
            </tr>
        </table>
    </div>
</div>
<div class='dijitDialogPaneActionBar'>
    <button id='repository_ok_button'>OK</button>
    <button id='repository_cancel_button'>Cancel</button>
</div>
<script type='text/javascript'>
    require([
        'dojo/store/Memory',
        'dijit/form/Form',
        'dijit/form/ValidationTextBox',
        'dijit/form/Button',
        'stalker/js/submitForm',
        'dojo/domReady!'
    ], function (Memory, Form, ValidationTextBox, Button, submitForm) {

        // ********************************************************************
        // Generate default values
        var url;
        var name;
        var linux_path;
        var windows_path;
        var osx_path;
        var additional_data = {};

        {% if mode=='CREATE' %}
            url = '{{ request.route_url('create_repository') }}';
        {% elif mode=='UPDATE' %}
            url = '{{ request.route_url('update_repository', id=repo.id) }}';
            name = '{{ repo.name }}';
            linux_path = '{{ repo.linux_path }}';
            windows_path = '{{ repo.windows_path }}';
            osx_path = '{{ repo.osx_path }}';
            additional_data = {
                repo_id: {{ repo.id }}
            };
        {% endif %}



        // **********************************************************************
        // Form
        var repository_form = new Form({}, 'repository_form');
        repository_form.startup();

        var dialog = repository_form.getParent();


        // **********************************************************************
        // Name
        var name_textBox = new ValidationTextBox({
            name: 'name',
            label: 'Name',
            placeHolder: 'Enter a Name',
            required: true,
            value: name
        }, 'repository_name');
        name_textBox.startup();


        // **********************************************************************
        // Windows Path
        var windows_path_textBox = new ValidationTextBox({
            name: 'windows_path',
            label: 'Windows Path',
            placeHolder: 'Enter the Windows Path',
            required: true,
            value: windows_path
        }, 'repository_windows_path');
        windows_path_textBox.startup();


        // **********************************************************************
        // Linux Path
        var linux_path_textBox = new ValidationTextBox({
            name: 'linux_path',
            label: 'Linux Path',
            placeHolder: 'Enter the Linux Path',
            required: true,
            value: linux_path
        }, 'repository_linux_path');
        linux_path_textBox.startup();


        // **********************************************************************
        // OSX Path
        var osx_path_textBox = new ValidationTextBox({
            name: 'osx_path',
            label: 'OSX Path',
            placeHolder: 'Enter the OSX Path',
            required: true,
            value: osx_path
        }, 'repository_osx_path');
        osx_path_textBox.startup();


        // **********************************************************************
        // Ok Button
        var ok_button = new Button({
            label: 'OK',
            type: 'button',
            onClick: function () {
                submitForm({
                    dialog: dialog,
                    form: repository_form,
                    additional_data: additional_data,
                    url: url,
                    method: 'POST'
                });
            }
        }, 'repository_ok_button');
        ok_button.startup();


        // **********************************************************************
        // Cancel Button
        var cancel_button = new Button({
            label: 'Cancel',
            type: 'button',
            onClick: function () {
                dialog.destroyRecursive();
            }
        }, 'repository_cancel_button');
        cancel_button.startup();

    });
</script>

